package org.fastsyncer.manager.canel;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.json.JSONArray;

public class CanelClient {

	public static void main(String[] args) {
		Map<String, String> map = new HashMap<String, String>();
		map.put("ip", "127.0.0.1");
		map.put("port", "11111");
		map.put("instance", "example");
//		map.put("database", "test");
//		map.put("table", "user");
		map.put("database", "TEST");
		map.put("table", "ASD_TEST");

		System.out.println("启动增量监听进程服务");
		while (true) {

			// 获取连接器binlog日志
			JSONArray msg = CanelRemoteClient.getInstance().pull(map);
			if (msg != null && msg.length() > 0) {
				System.out.println(msg);
			}

			try {
				System.out.println(new Date());
				Thread.sleep(3000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
